package thread.Test;

class MyThreadF extends Thread {
	public MyThreadF(String name) {
		super(name);
	}

	public void run() {
		for (int i = 0; i < 5; i++) {
			System.out.println(Thread.currentThread().getName() + "("
					+ Thread.currentThread().getPriority() + ")" + ", loop "
					+ i);
		}
	}
};

public class PriorityTest {
	public static void main(String[] args) {

		System.out.println(Thread.currentThread().getName() + "("
				+ Thread.currentThread().getPriority() + ")");

		Thread t1 = new MyThreadF("t1"); // 新建t1
		Thread t2 = new MyThreadF("t2"); // 新建t2
		t1.setPriority(1); // 设置t1的优先级为1
		t2.setPriority(10); // 设置t2的优先级为10
		t1.start(); // 启动t1
		t2.start(); // 启动t2
	}
}
/*
main(5)
t2(10), loop 0
t2(10), loop 1
t2(10), loop 2
t2(10), loop 3
t2(10), loop 4
t1(1), loop 0
t1(1), loop 1
t1(1), loop 2
t1(1), loop 3
t1(1), loop 4
*/